<?php


include('database.php');


function sql_exec($sql)
{
	$result = mysql_query($sql) or die ("could not $sql: " . mysql_error() . "\n");
	return $result;
}


// together, Domain and Line_Number are a unique ID for instances
// DROP TABLES

sql_exec("DROP TABLE IF EXISTS Instances, Definitions, Variables, Vals, Users");



// CREATE TABLES

// Updated should be here instead of in Domain because we want to know which line to jump to
// for editing
sql_exec("CREATE TABLE IF NOT EXISTS Instances (
	User			VARCHAR(100)	NOT NULL, 
	Domain		VARCHAR(100)	NOT NULL,
	Line_Number	INT				NOT NULL, 
	Fxn_Call		VARCHAR(100)	NOT NULL, 
	Returns_To	INT				NULL, 
	Var1			INT				NULL, 
	Var2			INT				NULL, 
	Var3			INT				NULL, 
	Var4			INT				NULL, 
	Var5			INT				NULL, 
	Var6			INT				NULL,
	Var1_Text		VARCHAR(100)	NULL, 
	Var2_Text		VARCHAR(100)	NULL, 
	Var3_Text		VARCHAR(100)	NULL, 
	Var4_Text		VARCHAR(100)	NULL, 
	Var5_Text		VARCHAR(100)	NULL, 
	Var6_Text		VARCHAR(100)	NULL, 
	Bonus_Field	TEXT			NULL, 
	Comments	TEXT			NULL,
	Updated		INT				NULL 
	)");


sql_exec("CREATE TABLE IF NOT EXISTS Definitions (
	ID			INT				NOT NULL	AUTO_INCREMENT,
	Fxn_Call		VARCHAR(200)	NOT NULL, 
	English_Name	VARCHAR(100)	NULL, 
	Description	VARCHAR(230)	NOT NULL, 
	Category		VARCHAR(50)		NULL, 
	User			VARCHAR(100)	NULL, 
	Var1			VARCHAR(100)	NULL, 
	Var2			VARCHAR(100)	NULL, 
	Var3			VARCHAR(100)	NULL, 
	Var4			VARCHAR(100)	NULL, 
	Var5			VARCHAR(100)	NULL, 
	Var6			VARCHAR(100)	NULL, 
	Returns_To	VARCHAR(100)	NULL,
	Required		INT				NULL,
	UNIQUE KEY(ID) 
	)");
	
// there has to be a dummy variable inserted when a user-defined definition (a new domain) is added
// with Name as NULL, or memory.php won't allow new variables to be defined for that domain.  
sql_exec("CREATE TABLE IF NOT EXISTS Variables (
	ID			INT				NOT NULL	AUTO_INCREMENT,
	User			VARCHAR(100)	NULL, 
	Domain		VARCHAR(100)	NULL, 
	Name		VARCHAR(100)	NULL, 
	Description	TEXT		NULL, 
	UNIQUE KEY(ID))");


// holds a literal for an instance at Domain at Line Number for Variable Var_Name, e.g. Var2
// null values act as placeholders 
sql_exec("CREATE TABLE IF NOT EXISTS Vals (
	User			VARCHAR(100)	NOT NULL, 
	Value		TEXT			NULL, 
	Domain		VARCHAR(100)	NOT NULL,
	Line_Number	INT				NOT NULL, 
	Var_Name	VARCHAR(20)		NULL)");
	
sql_exec("CREATE TABLE IF NOT EXISTS Users (
	User			VARCHAR(100)	NOT NULL, 
	Password		VARCHAR(100)	NOT NULL,
	Email		VARCHAR(100)	NULL,
	Blurb		VARCHAR(255)	NULL,
	UNIQUE KEY(User)
	)");

echo "<p>tables created.</p>\n";


sql_exec("INSERT INTO Variables SET ID=-1, Name='='");
sql_exec("INSERT INTO Variables SET ID=-2, Name='≠'");
sql_exec("INSERT INTO Variables SET ID=-3, Name='<'");
sql_exec("INSERT INTO Variables SET ID=-4, Name='≤'");
sql_exec("INSERT INTO Variables SET ID=-5, Name='≥'");
sql_exec("INSERT INTO Variables SET ID=-6, Name='>'");
sql_exec("INSERT INTO Variables SET ID=-7, Name='+'");
sql_exec("INSERT INTO Variables SET ID=-8, Name='−'");
sql_exec("INSERT INTO Variables SET ID=-9, Name='×'");
sql_exec("INSERT INTO Variables SET ID=-10, Name='÷'");

// MAGIC NUMBERS
// sorry
// -11 means 'Constant'
sql_exec("INSERT INTO Variables SET ID=-11, Name='[ Constant ]'");


// user's main function (home) will be their login ID

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='str_replace', 
	English_Name='Text Replacement', 
	Description='Text Replace',
	Var1='Search For', 
	Var2='Replace With', 
	Var3='Search In',
	Category='Text', 
	Returns_To='Result'");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='store', 
	Category='Memory',
	English_Name='Store a Variable in a Variable', 
	Description='Stores a variable in a variable.',
	Var1='Value', 
	Returns_To='Variable'");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='store_constant', 
	Category='Memory',
	English_Name='Store a Constant in Variable', 
	Description='Stores a constant in a variable.',
	Returns_To='Variable'");
	
// store_in_table
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='store_in_table', 
	English_Name='Store in a Table', 
	Description='use this to put something into a table.' ");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='delete_from_table', 
	English_Name='Delete from a Table', 
	Description='delete something from a table.'");

// go through a table
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='database', 
	English_Name='Go Through a Table', 
	Description='retrieve each row of the table you choose one at a time.  the indented part is repeated for each row of the table.'");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='concatenate', 
	English_Name='Concatenate', 
	Description='stick two things together',
	Var1='Fragment 1', 
	Var2='Fragment 2', 
	Category='Text', 
	Returns_To='Result'");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='arithmetic', 
	English_Name='Arithmetic', 
	Description='do arithmetic',
	Var1='x', 
	Var2='operation', 
	Var3='y',
	Category='Math',
	Returns_To='Result'");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='if', 
	English_Name='If', 
	Description='if the comparison is true, do the indented part once.', 
	Category='Flow', 
	Var1='Left Side', 
	Var2='Is', 
	Var3='Right Side' 
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='while', 
	English_Name='While', 
	Description='do the indented part as long as the comparison is true.  that is, don\'t quit until the comparison is false.  be careful with this one.', 
	Category='Flow', 
	Var1='Left Side', 
	Var2='Is', 
	Var3='Right Side' 
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='for', 
	English_Name='Count Through', 
	Description='go from one number to another.  start at \'from\', do the indented part, add one to \'counter\', do the indented part, and continue until you get to \'to\'.  this one is very useful.', 
	Category='Flow', 
	Var1='Counter', 
	Var2='From', 
	Var3='To' 
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='return', 
	English_Name='Return', 
	Category='Flow', 
	Description='Return to the page that called this one, and you can return a value if you want to.', 
	Var1='Return Value'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='addslashes', 
	English_Name='Add Backslashes', 
	Description='Inserts backslashes before characters that may do special things in database entries.',  
	Var1='Text',
	Category='Text', 
	Returns_To='Text With Backslashes'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='bin2hex', 
	English_Name='Binary to Hexadecimal', 
	Description='Converts a number in binary representation to hexadecimal representation.', 
	Category='Math', 
	Var1='Binary Number',
	Returns_To='Hexadecimal Number'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='chr', 
	English_Name='Character from ASCII', 
	Description='Returns the character designated by the given number in ASCII.', 
	Var1='Integer',
	Category='Text', 
	Returns_To='ASCII Character'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='chunk_split', 
	English_Name='Split into Chunks', 
	Description='Splits text into chunks of the same length.', 
	Var1='Text',
	Var2='Chunk Size',
	Var3='End Character',
	Category='Text', 
	Returns_To='Text in Chunks',
	Required=1
	");

// simple version
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='levenshtein', 
	English_Name='Levenshtein Distance', 
	Description='Calculates the Levenshtein distance between two text fragments..', 
	Var1='Text',
	Var2='Text',
	Category='Text', 
	Returns_To='Distance'
	");

	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='ltrim', 
	English_Name='Trim from Left Side', 
	Description='Trims blank space from the left side of a text fragment.', 
	Var1='Text',
	Category='Text', 
	Returns_To='Trimmed Text'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='metaphone', 
	English_Name='Metaphone Key', 
	Description='Calculates the metaphone key of some text, based on the rules of English pronounciation.', 
	Var1='Text',
	Category='Text', 
	Returns_To='Metaphone Key'
	");	
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='nl2br',
	Category='Text',  
	English_Name='Newlines to HTML Pagebreaks', 
	Description='Converts newline characters to HTML pagebreak tags.', 
	Var1='Text',
	Returns_To='Text with HTML Pagebreaks'
	");	
	
// simple
// add complicated ("extended"?) version or number_format later
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='number_format', 
	English_Name='Format a Number', 
	Description='Formats a number with commas between thousands and a given number of decimals.', 
	Var1='Number',
	Category='Text', 
	Var2='Number of Decimals',
	Returns_To='Text of Formatted Number'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='ord', 
	English_Name='ASCII Value of Character', 
	Category='Text', 
	Description='Returns the numeric ASCII value of the first character in a text fragment.', 
	Var1='Text',
	Returns_To='ASCII Value'
	");	

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='quotemeta', 
	English_Name='Quote Metacharacters', 
	Category='Text', 
	Description='Adds a backslash in front of metacharacters, specifically: . \ + * ? [ ^ ] ( $ )', 
	Var1='Text',
	Returns_To='Text with Backslashes'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='similar_text', 
	English_Name='Text Similarity', 
	Description='Calculates the similarity between two text fragments.', 
	Var1='Text',
	Var2='Text',
	Category='Text', 
	Returns_To='Similarity'
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='soundex', 
	English_Name='Soundex Key', 
	Category='Text', 
	Description='Calculates the soundex key of a text fragment.  Two text fragments with the same key have similar or identical pronounciations in English.', 
	Var1='Text',
	Returns_To='Soundex Key'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='str_ireplace', 
	Category='Text', 
	English_Name='Case-Insensitive Text Replace', 
	Description='Replaces one text fragment with another without regard to case.', 
	Var1='Search',
	Var2='Replace',
	Var3='Subject',
	Returns_To='Text with Replacements'
	");

// add fourth argument
// string str_pad  ( string $input  , int $pad_length  [, string $pad_string  [, int $pad_type  ]] )
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='str_pad', 
	English_Name='Text Pad', 
	Description='Pads a text fragment with another text fragment to a given length.  Default padding is spaces.', 
	Var1='Text',
	Category='Text', 
	Var2='Padding Length',
	Var3='Padding', 
	Returns_To='Padded Text',
	Required=2
	");

// string str_repeat  ( string $input  , int $multiplier  )
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='str_repeat', 
	English_Name='Text Repeat', 
	Description='Repeats a text fragment a given number of times.', 
	Var1='Text',
	Category='Text', 
	Var2='Number of Times to be Repeated',
	Returns_To='Text'
	");

// string str_rot13  ( string $str  )
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='str_rot13', 
	English_Name='ROT13 Transformation', 
	Description='Shifts all alpha characters in a text fragment up by 13 places in the alphabet.', 
	Category='Text', 
	Var1='Text',
	Returns_To='Text After Transformation'
	");

// string str_shuffle  ( string $str  )
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='str_shuffle', 
	English_Name='Character Shuffle', 
	Description='Randomly shuffles the characters in a text fragment.', 
	Var1='Text',
	Category='Text', 
	Returns_To='Shuffled Text Fragment'
	");

// int strcasecmp  ( string $str1  , string $str2  )
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='strcasecmp', 
	English_Name='Case-Insensitive Text Comparison', 
	Description='Returns a positive number if the first text fragment is greater than the second, negative for the reverse, and zero if they are equal.  Case-insensitive and binary safe.', 
	Category='Text', 
	Var1='Text',
	Var2='Text',
	Returns_To='Length Result'
	");
	
// int strcmp  ( string $str1  , string $str2  )
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='strcmp', 
	English_Name='Case-Sensitive Text Comparison', 
	Description='Returns a positive number if the first text fragment is greater than the second, negative for the reverse, and zero if they are equal.  Case-sensitive and binary safe.', 
	Category='Text', 
	Var1='Text',
	Var2='Text',
	Returns_To='Similarity'
	");

// int strcoll  ( string $str1  , string $str2  )
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='strcoll', 
	English_Name='Locale-based Text Comparison', 
	Description='Based on the character set for the set locale, returns a positive number if the first text fragment is greater than the second, negative for the reverse, and zero if they are equal.  Case-sensitive and not binary safe.', 
	Var1='Text',
	Var2='Text',
	Category='Text', 
	Returns_To='Similarity'
	");
	
// last string functions function added


// begin time & date functions

// bool checkdate  ( int $month  , int $day  , int $year  )
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='checkdate', 
	English_Name='Check Date', 
	Description='Checks a Gregorian Date.', 
	Var1='Month',
	Category='Time', 
	Var2='Day',
	Var3='Year', 
	Returns_To='Validity'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='date', 
	English_Name='Date and Time', 
	Category='Time', 
	Returns_To='Date and Time', 
	Description='Return the current date and time.'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='strtotime', 
	English_Name='Text to Timestamp', 
	Description='Tries to Go from an English Date to a UNIX Timestamp.', 
	Var1='Date in English',
	Var2='Relative to This Timestamp',
	Category='Time', 
	Required=1,
	Returns_To='Timestamp'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='time', 
	English_Name='Current Timestamp', 
	Description='Return the current UNIX timestamp.', 
	Category='Time', 
	Returns_To='Current Timestamp'
	");

// DATE/TIME FUNCTIONS DONE



// IO FUNCTIONS
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='echo', 
	English_Name='Display', 
	Description='display it.  plops it onto the web page.', 
	Category='IO', 
	Var1='what you want to display'
	");

// Var1 is actually the definition ID of the destination page
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='form', 
	English_Name='Form', 
	Category='IO', 
	Description='you need to add this first to make a form.  add this, then put form inputs inside it.', 
	Var1='Destination Page' 
	");
	
// we want this to show up so the end is visible and things can be inserted in the middle
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='endform', 
	English_Name='Form End', 
	Description='The End of an HTML Form'
	");
	
// don't give this a category since it should only be offered for lines inside a form
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='form_input', 
	English_Name='Form Input', 
	Description='Input in a Form', 
	Var1='the input\'s name.  you will see this as a variable when you edit the page that this page goes to when you click \'submit\' in the form.',
	Var2='caption.  this is what shows up on the web page and doesn\'t matter otherwise.',
	Required=1
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='a', 
	English_Name='Link', 
	Description='a link.  put a link inside \'the link\' but be sure to make it complete.', 
	Category='IO', 
	Var1='the link', 
	Var2='the blue underlined text that you click on, not the link itself' 
	");

// don't give this a category since it should only be offered for lines inside a form
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='select', 
	English_Name='Dropdown', 
	Description='Display a dropdown menu.', 
	Var1='the menu\'s name.  you will see this as a variable when you edit the page that this page goes to when you click \'submit\' in the form.', 
	Var2='caption.  this shows up on the web page and should explain what the menu is.' 
	");

// don't give this a category since it should only be offered for lines inside a form 
// AND a dropdown menu
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='option', 
	English_Name='Dropdown Menu Item', 
	Description='the choices that go in a dropdown menu.', 
	Var1='the value that gets sent to the page that this form goes to.  it\'s the actual value of this option.', 
	Var2='title that the you see as this choice on the web page.' 
	");





// MATH FUNCTIONS
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='abs', 
	English_Name='Absolute Value', 
	Description='Returns the absolute value of a number.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Absolute Value'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='acos', 
	English_Name='Arc Cosine', 
	Description='Returns the arc cosine of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Arc Cosine'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='acosh', 
	English_Name='Inverse Hyperbolic Cosine', 
	Description='Returns the inverse hyperbolic cosine of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Inverse Hyperbolic Cosine'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='asin', 
	English_Name='Arc Sine', 
	Description='Returns the arc sine of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Arc Sine'
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='asinh', 
	English_Name='Inverse Hyperbolic Sine', 
	Description='Returns the inverse hyperbolic sine of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Inverse Hyperbolic Sine'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='atan', 
	English_Name='Arc Tangent', 
	Description='Returns the arc tangent of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Arc Tangent'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='atanh', 
	English_Name='Inverse Hyperbolic Tangent', 
	Description='Returns the inverse hyperbolic tangent of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Inverse Hyperbolic Tangent'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='base_convert', 
	English_Name='Convert Bases', 
	Description='Converts a number (as text) from one base to another, e.g. from decimal to binary.', 
	Var1='Number (Text)',
	Var2='Original Base',
	Var3='Desired Base',
	Category='Math', 
	Returns_To='Converted (Text)'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='bindec', 
	English_Name='Binary to Decimal', 
	Description='Converts a binary number (as text) to a real number.', 
	Var1='Binary Number',
	Category='Math', 
	Returns_To='Number'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='ceil', 
	English_Name='Round Up', 
	Description='Returns a number with the fraction, if it existed, rounded up.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Rounded Number'
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='cos', 
	English_Name='Cosine', 
	Description='Returns the cosine of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Cosine'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='cosh', 
	English_Name='Hyperbolic Cosine', 
	Description='Returns the hyperbolic cosine of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Hyperbolic Cosine'
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='decbin', 
	English_Name='Decimal to Binary', 
	Description='Returns a binary number (as text) equal to a given (normal) decimal number.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Binary Number'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='dechex', 
	English_Name='Decimal to Hexadecimal', 
	Description='Returns a hexadecimal number (as text) equal to a given (normal) decimal number.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Hexadecimal Number'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='decoct', 
	English_Name='Decimal to Octal', 
	Description='Returns an octal number (as text) equal to a given (normal) decimal number.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Octal Number'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='deg2rad', 
	English_Name='Degrees to Radians', 
	Description='Converts an angle in degrees to radians.', 
	Var1='Degrees',
	Category='Math', 
	Returns_To='Radians'
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='exp', 
	English_Name='Exponent of e', 
	Description='Calculates the exponent of e.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Exponent of e'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='floor', 
	English_Name='Round Down', 
	Description='Rounds down a number, if there was a fractional part.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Rounded Down'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='fmod', 
	English_Name='Remainder', 
	Description='Returns the fractional remainder (modulo) for x/y.', 
	Var1='x',
	Var2='y', 
	Category='Math', 
	Returns_To='Remainder'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='hexdec', 
	English_Name='Hexadecimal to Decimal', 
	Description='Returns a decimal (normal) number from a hexidecimal number (as text.)', 
	Var1='Hexadecimal Number',
	Category='Math', 
	Returns_To='Decimal Number'
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='hypot', 
	English_Name='Hypotenuse', 
	Description='Calculates the length of the hypotenuse of a right triangle.', 
	Var1='First Leg',
	Var2='Second Leg', 
	Category='Math', 
	Returns_To='Hypotenuse'
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='log10', 
	English_Name='Base 10 Logarithm', 
	Description='Calculates the base-10 logarithm of a number.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Logarithm'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='log', 
	English_Name='Logarithm', 
	Description='Returns logarithm of a number at a given base, or the natural logarithm if no base is given.', 
	Var1='Number',
	Var2='Base', 
	Category='Math', 
	Returns_To='Logarithm', 
	Required=1
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='mt_rand', 
	English_Name='Random Number', 
	Description='Generates a random number (no fractional part) between Min and Max.', 
	Var1='Min',
	Var2='Max', 
	Category='Math', 
	Returns_To='Random Number'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='octdec', 
	English_Name='Octal to Decimal', 
	Description='Returns the decimal equivalent of an octal number (as text.)', 
	Var1='Octal Number',
	Category='Math', 
	Returns_To='Decimal Number'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='cosh', 
	English_Name='Hyperbolic Cosine', 
	Description='Returns the hyperbolic cosine of a number in radians.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Hyperbolic Cosine'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='pi', 
	English_Name='Pi', 
	Description='Returns a good approximation of pi.', 
	Category='Math', 
	Returns_To='Pi'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='pow', 
	English_Name='Raise to a Power', 
	Description='Calculates the result of Base raised to the power Exponent.', 
	Var1='Base',
	Var2='Exponent', 
	Category='Math', 
	Returns_To='Power'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='rad2deg', 
	English_Name='Radians to Degrees', 
	Description='Converts an angle in radians to degrees.', 
	Var1='Angle in Radians',
	Category='Math', 
	Returns_To='Angle in Degrees'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='round', 
	English_Name='Round', 
	Description='Rounds a number up or down depending on which is closer to the given number of digits after the decimal.  Default number of digits is zero', 
	Var1='Number',
	Var2='Digits', 
	Category='Math', 
	Returns_To='Rounded Number',
	Required=1
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='sin', 
	English_Name='Sine', 
	Description='Returns the sine of an angle in radians.', 
	Var1='Angle',
	Category='Math', 
	Returns_To='Sine'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='sinh', 
	English_Name='Hyperbolic Sine', 
	Description='Returns the hyperbolic sine of an angle in radians.', 
	Var1='Angle',
	Category='Math', 
	Returns_To='Hyperbolic Sine'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='sqrt', 
	English_Name='Square Root', 
	Description='Returns the square root of a number.', 
	Var1='Number',
	Category='Math', 
	Returns_To='Square Root'
	");

sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='tan', 
	English_Name='Tangent', 
	Description='Calculates the tangent of an angle in radians.', 
	Var1='Angle in Radians',
	Category='Math', 
	Returns_To='Tangent'
	");
	
sql_exec("INSERT INTO Definitions SET 
	Fxn_Call='tanh', 
	English_Name='Hyperbolic Tangent', 
	Description='Calculates the hyperbolic tangent of an angle in radians.', 
	Var1='Angle in Radians',
	Category='Math', 
	Returns_To='Hyperbolic Tangent'
	");

	

echo "<p>defs put into db</p>\n";

echo "<p><a href=\"login.php\">register</a></p>";

